<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<title>选择车型</title>
		<link rel="stylesheet" href="<%=path %>/css/amazeui.min.css" />
		<link rel="stylesheet" href="<%=path %>/css/wgj_style.css" />
		<script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
		<script type="text/javascript" src="<%=path %>/js/amazeui.min.js"></script>
		<script type="text/javascript">
			function toDingdan(carTypeNam,hourPrice,typeId){
				var date=$("#date").val();
				var nowDate=new Date().getTime();
				date=date.replace("年","/").replace("月","/").replace("日","")+":00";
				date=new Date(date).getTime();
				var diff=(date-nowDate)/(1000*60);
				if(diff<=60&&diff>0){
					$("#typeId").val(typeId);
					$("#typeName").val(carTypeNam);
					$("#hourPrice").val(hourPrice);
					$("#form1")[0].submit();
				}else{
					alert("必须预定一小时以内的车");
				}
			} 
			function queryPriceDoc(id,typeId){
				var fenId=$("#fenId").val();
				var memberlevel=$("#memberlevel").val();
				var url="<%=path%>/carType/queryOtherPriceJson";
				var data={"typeId":typeId,"fenId":fenId,"memberlevel":memberlevel};
				$.post(url,data,function(data){
					$("#"+id).html("");
					if(data.rh!=null){
						var html="";
						if(data.rh.HOURLIMITKM!=null&&data.rh.HOURLIMITKM!=""){
							html+="<li><span>"+data.rh.HOURLIMITKM+"公里/小时</span><br />时限里程</li>";
						}
						if(data.rh.OVERDRIVEFEEUNIT!=null&&data.rh.OVERDRIVEFEEUNIT!=""){
							html+="<li><span>￥"+data.rh.OVERDRIVEFEEUNIT+"公里/元</span><br />超里程费</li>";
						}
						if(data.rh.CARDEPOSIT!=null&&data.rh.CARDEPOSIT!=""){
							html+="<li><span>￥"+data.rh.CARDEPOSIT+"元</span><br />违章押金</li>";
						}
						$("#"+id).append(html);
					}
				});
			}
		</script>
	</head>
	
	<body>
	<section>
		<form action="<%=path %>/carType/querOtherPrice" method="post" id="form1">
			<input type="hidden" name="reserveHour.TerminalName" value="${dept.deptName }" /><!-- 部门名称 -->
			<input type="hidden" name="reserveHour.TerminalAddress" value="${dept.deptaddress }"   />	<!-- 场站地点-->
			<input type="hidden" name="reserveHour.carTypeId" value="" id="typeId" />  <!--车型Id  -->
			<input type="hidden" name="reserveHour.carType" value="" id="typeName" />  <!-- 车型名称 -->
			<input type="hidden" name="reserveHour.carLocalId" value="${dept.deptId }" />	<!-- 部门Id -->
			<input type="hidden" name="reserveHour.usefencomid" value="${dept.fencom }" id="fenId" />	<!-- 分公司ID -->
			<input type="hidden" name="reserveHour.usecomid" value="${dept.DEPTINCID }"  />	<!-- 总公司公司ID -->
			<input type="hidden" name="reserveHour.hourFee" value="" id="hourPrice" />	<!-- 时租价格 -->
			<input type="text" name="reserveHour.clientName" value="${client.cliename }"  />	<!-- 预定人 -->
			<input type="text" name="reserveHour.clientId" value="${client.clieid }"  />	<!-- 预定人Id -->
			<input type="text" name="reserveHour.clientPhone" value="${client.telone }" /> <!-- 预订人电话 -->
			<input type="hidden" name="date" value="${date }" id="date"  />	<!-- 预定时间 -->
			<input type="text" value="${client.memberlevel }" id="memberlevel" />
		</form>
	    <div class="am-panel-group" id="accordion">
	    	<c:if test="${!empty carTypes }">
	    	<c:forEach items="${carTypes }" var="carType" varStatus="s">
	    		<div class="am-panel clear">
			            <dl class="am-panel-hd carbox">
			            	<dt><img src="<%=path %>/image/K10.png" /></dt>
			                <dd class="car_infor">
			                	<h2>${carType.tcm_wholeName }</h2>
			                    <p>${carType.fcbp_baseprice }元/小时</p>
			                    <p>${dept.deptName }</p>
			                	<p class="am-panel-title" data-am-collapse="{parent:'#accordion',target:'#do-not-say-${s.count }'}" onclick="queryPriceDoc('priceDoc-${s.count }',${carType.tcm_id });">查看价格详情</p>
			                </dd>
			                <c:if test="${carType.carCount>0 }">
			                	<dd class="choose"><a class="xz_btn" href="javascript:void(0);" onclick="toDingdan('${carType.tcm_wholeName }',${carType.fcbp_baseprice },${carType.tcm_id });">选择</a></dd>
							</c:if>
							<c:if test="${carType.carCount==0}">
								<dd class="choose"><a class="xz_btn" href="javascript:void(0);">租满</a></dd>
							</c:if>
			            </dl>
			            <div id="do-not-say-${s.count }" class="am-panel-collapse am-collapse selbox">
			              	<div class="am-panel-bd">
			                	<h3>${carType.tcm_wholeName }</h3>
			                	<ul id="priceDoc-${s.count }">
			                    </ul>
			              	</div>
			            </div>
			      	</div>
	  			</c:forEach>
	  			</c:if>
	  			<c:if test="${empty carTypes }">
	  				该场站下没有可用的车型
	  			</c:if>
	    </div>
	</section>
	</body>
</html>

